#ifndef MODEL_H
#define MODEL_H

#include "Relation.h"
#include "NodeIterator.h"
#include "RelationIterator.h"
#include "Graph.h"
#include <vector>
#include <boost/shared_ptr.hpp>

namespace SemanticModel
{
	class Model : public Graph
	{
	private:
		NameMap _names;
		VertexMap _vertexes;

	public:
		Model();

		void addEssense(const wchar_t* name) { addVertex(name, EssenseNode); }		
		void addOperation(const wchar_t* name) { addVertex(name, OperationNode); }
		void addRelation(const wchar_t* roleA, const Relation& relation, const wchar_t* roleB);

		typedef std::pair<NodeIterator, NodeIterator> Nodes;
		Nodes nodes(NodeType type = NoneNode) const;

		typedef RelationIterator<boost::graph_traits<Graph>::edge_iterator> RelationAll;
		typedef std::pair<RelationAll, RelationAll> RelationsAll;
		RelationsAll relations(RelationType type = NoneRelation) const;
		
		typedef RelationIterator<boost::graph_traits<Graph>::out_edge_iterator> RelationOut;
		typedef std::pair<RelationOut, RelationOut> RelationsOut;
		RelationsOut relations(const NodeIterator& nodeFrom, RelationType type = NoneRelation) const;
		RelationsOut relations(const wchar_t* nodeFrom, RelationType type = NoneRelation) const;
		RelationsOut relations(vertex_descriptor nodeFrom, RelationType type = NoneRelation) const;

		bool empty() const { return _names.empty(); }
	private:
		bool addVertex(const wchar_t* name, NodeType type);
	};

	typedef boost::shared_ptr<Model> ModelPtr;
}

#endif // MODEL_H